<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>商家登录页面</title>
<jsp:include page="/base.jsp"/>

</head>
<body>
	<form id="form_login">
		<h3 id="info" style="color: red;"></h3>
		用户账号：<input name="userCode"><br>
		用户密码：<input name="userPass" type="password"><br>
		<input type="submit" value="登录" id="btn_submit"><br>
	</form>
</body>
<script type="text/javascript" src="assert/jquery/jquery-3.4.1.js"></script>
<script type="text/javascript">
	
	$(document).ready(function(){
		//给提交按钮绑定点击事件
		$('#btn_submit').on('click',function(){
			console.log('绑定了点击事件');
			console.log($('#form_login').serialize());
			//发起一个ajax请求，进行登录的请求
			$.ajax({
				type:'post',//表单提交的方式
				url:'user/dologin2', 
				data:$('#form_login').serialize(),
				success:function(result){
					console.log("登陆成功="+result);
					if(result==1){//进首页
						location.href="user/index2";
					}else{
						$('#info').text("用户名或密码错误!");
					}
				}
			});
			return false;
		});
		
	});
</script>
</html>



